package algorithm.tree.multitree.postorder;

import algorithm.tree.binarytree.base.TreeNode;
import algorithm.tree.multitree.base.MTreeNode;

import java.util.function.Consumer;

public class MTreePostorderRecursion {
    public void traverse(MTreeNode node, Consumer<MTreeNode> consumer) {
        if (node != null) {
            for (int i = 0; i < node.getNodeList().size(); i++) {
                traverse(node.getNodeList().get(i), consumer);
            }
            consumer.accept(node);
        }
    }
}
